package com.cuckoo.mall.thus.goodmultipledetail;

import android.content.Context;

import com.bgn.baseframe.base.BasePresenterImpl;
import com.bgn.baseframe.network.HttpObserver;
import com.bgn.baseframe.network.bean.TDataBean;
import com.cuckoo.mall.javabean.Goods;
import com.cuckoo.mall.javabean.Product;
import com.cuckoo.mall.network.ApiManager;


/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class GoodMultipleDetailPresenter extends BasePresenterImpl<GoodMultipleDetailContract.View> implements GoodMultipleDetailContract.Presenter {
    @Override
    public void loadGoodsInfo(String product_id) {
        ApiManager.getGoodInfo(product_id).subscribe(new HttpObserver<TDataBean<Product>>(mView) {
            @Override
            public void onSucceed(TDataBean<Product> value) {
                if (value.getData() != null) {
                    mView.whenGetGoodInfo(value.getData());
                }
            }
        });
    }

    @Override
    public void addFavorite(String product_id) {
        ApiManager.addFavorite(product_id).subscribe(new HttpObserver<TDataBean>(mView) {
            @Override
            public void onSucceed(TDataBean value) {
                mView.whenAddFavoriteSucceed();
            }
        });

    }

    @Override
    public void delFavorite(String product_id) {
        ApiManager.cancleFavorite(product_id).subscribe(new HttpObserver<TDataBean>(mView) {
            @Override
            public void onSucceed(TDataBean value) {
                mView.whencancleFavoriteSucceed();
            }
        });
    }

}
